package com.guaoran.common.datasource;

/**
 * @author : guaoran
 * @Description 数据源类型管理类
 * @date :2019/4/15 21:28
 */
public class DataSourceTypeManager {
    private static final ThreadLocal<DataSources> dataSourceTypes = new ThreadLocal<DataSources>(){
        // 默认是 master
        @Override
        protected DataSources initialValue(){
            return DataSources.MASTER;
        }
    };

    public static DataSources get(){
        return dataSourceTypes.get();
    }

    public static void set(DataSources dataSourceType){
        dataSourceTypes.set(dataSourceType);
    }

    public static void reset(){
        dataSourceTypes.set(DataSources.MASTER);
    }
}
